/*
 * @lc app=leetcode.cn id=1103 lang=javascript
 *
 * [1103] 分糖果 II
 */

// @lc code=start
/**
 * @param {number} candies
 * @param {number} num_people
 * @return {number[]}
 */
var distributeCandies = function(candies, num_people) {
    var arr = new Array(num_people).fill(0)
    let num = 0
    while (candies > num) {
        arr[(num % num_people)] += ++num
        candies -= num
    }
    arr[(num % num_people)] += candies
    return arr
};
// @lc code=end

